<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

class CreateMerchantRegistersTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('merchant_registers', function (Blueprint $table) {
            $table->id()->comment('商户申请表');
            $table->integer('user_id')->comment('用户id')->index();
            $table->tinyInteger('class')->default(0)->comment('商户类别 0:自营 1:非自营')->index();
            $table->string('name')->comment('商户名称店铺名')->index();
            $table->tinyInteger('move_show')->default(1)->comment('是否可在移动端展示 0:不展示 1:展示');
            $table->string('banner')->nullable()->comment('商户店铺展示图片');
            $table->text('brief')->nullable()->comment('商户简介');
            $table->string('avatar')->default('a.png')->comment('商户店铺头像');
            $table->string('principal_name',50)->nullable()->comment('负责人姓名');
            $table->char('principal_phone',15)->nullable()->comment('负责人电话');
            $table->json('license')->comment('商户资质 营业执照 食品经营许可证等等');
            $table->string('keyword')->nullable()->comment('商户关键字');
            $table->char('service_phone',15)->nullable()->comment('客服电话');
            $table->string('province')->comment('商户所在省');
            $table->string('city')->comment('商户所在市');
            $table->string('district')->comment('商户所在区');
            $table->string('detailed_address')->nullable()->comment('商户详细地址');
            $table->decimal('fees',10,2)->comment('商户手续费 百分比 例0.1');
            $table->tinyInteger('add_product_right')->default(0)->comment('添加商品权限 0:需平台审核 1:无需平台审核');
            $table->tinyInteger('open_live_room')->default(0)->comment('开启直播间权限 0:需平台审核 1:无需平台审核');
            $table->tinyInteger('add_live_room_product')->default(0)->comment('添加直播商品权限 0:需平台审核 1:无需平台审核');
            $table->tinyInteger('home_recommend')->default(0)->comment('是否为平台首页推荐商户 0:否 1:是');
            $table->tinyInteger('merchant_type')->nullable()->comment('商户店铺类型 0:专卖店 1:官方旗舰店')->index();
            $table->string('status',50)->default('underreview')->comment('店铺审核状态 underreview:审核中 approved:审核通过 auditfailed:审核未通过')->index();
            $table->timestamp('check_time')->nullable()->comment('申请审核通过未通过时间');
            $table->string('fail_message',1000)->nullable()->comment('申请未通过原因');
            $table->softDeletes();
            $table->timestamps();
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('merchant_registers');
    }
}
